<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>


		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		<div id="app">
			学生成绩:<input type="text" v-model="score" /><br>
			{{score}}<br>
			{{result}}
		</div>

		<script>
			var app = Vue.createApp({
				data() {
					return {
						"message": "Hello Vue!",
						"score": 0,
						"result": ""
					}
				},
				methods: {
					judge() {
						this.result = "正在运算，请稍后"

						setTimeout(() => {
							if (this.score >= 90 && this.score <= 100) {
								this.result = "优秀"
							} else if (this.score >= 80) {
								this.result = "良好"
							} else if (this.score >= 70) {
								this.result = "中等"
							} else if (this.score >= 60) {
								this.result = "及格"
							} else if (this.score < 60) {
								this.result = "不及格"
							}
						}, 2000);
					}
				},
				watch: {
					// score(newVal, oldVal) {
						score: 'judge'
						// console.log(newVal);

						// if (newVal >= 90 && newVal <= 100) {
						// 	this.result = "优秀"
						// } else if (newVal >= 80) {
						// 	this.result = "良好"
						// } else if (newVal >= 70) {
						// 	this.result = "中等"
						// } else if (newVal >= 60) {
						// 	this.result = "及格"
						// } else if (newVal < 60) {
						// 	this.result = "不及格"
						// }

						// 90-100 优秀
						// 80
						// 70
						// 60
					// }
				}
			});
			var vm = app.mount("#app")
		</script>
	</body>
</html>
